Skip to main content

Remap keys

ยท 5 min read
Marcel Scherzer

After developing the muscle memory for navigating text with the H, J, K and L keys while developing with VIM or VS Code with the VIM plugin, I now find it very distracting to have to move my hand to use the arrow keys for moving around text or even to just select an option from a drop-down in other applications. It just feels jarring when working.

What I want is an operating system-wide solution that affords me the ability to use H, J, K, L instead of needing to use the cursor/arrow keys; the keys are typically positioned such that they are just too difficult to access without moving the right hand.

There are some challenges in finding a generic solution. The main challenge lies in avoiding overwriting any existing shortcuts inside the operating system or in any of the many applications installed on my machine. The other problem is that to be easily accessible whatever modifier I decided on it would need to be activated with the left hand.

Luckily, for me like for many users I don't have much use for Caps-Lock making it the ideal key to repurpose to a modifier for all my bespoke shortcuts.

The idea is that as long as I hold down caps-lock I would be able to use HJKL as arrow keys with the keyboard reverting to normal mode as soon as I released caps-lock.

With the aforementioned plan in mind, I found implementations for both Windows and Mac OS that I have outlined below.

While I have only just implemented this change on my system I am already getting used to the little tweak which is making life just a little bit better when working with text on my machines.

Give the above a shot, you might be surprised how nice it is to not use the arrow keys once you developed the necessary muscle memory.

๐Ÿบ Happy Coding! ๐Ÿค˜

Windowsโ€‹

Required hardware/softwareโ€‹

This tip will likely also work with the tools for remapping keys provide by other keyboard brands.

Configure CAPS-Lockโ€‹

  1. Open iCUE, select your keyboard and navigate to "Key Assignment".
  2. Click + inside the "Assignments" panel.
  3. Select "Keystroke"
  4. Select "Key and click "Caps Lock" on the keyboard image.
  5. In the "Remap: Keystroke" pane type: alt + shift +ctrl (using the right-hand keys)

Pay attention that caps-lock is in the correct state as the caps lock key will stop fuctioning as caps lock after remapping.

Setup shortcuts in PowerToysโ€‹

  1. Open Power Toys
  2. Select the "Keyboard Manager" tool.
  3. Click "Remap shortcuts"
  4. Select and then type alt +shift + ctrl and h
  5. To send (Key/Shortcut) select "Right" from the dropdown.
  6. Click ok

You can now use caps-lock + h as the left arrow key.

Useful Short Cutsโ€‹

Short CutAction
Ctrl(Right) + Alt(Right) + Shift (Right) + SpaceEsc
Ctrl(Right) + Alt(Right) + Shift (Right) + HLeft
Ctrl(Right) + Alt(Right) + Shift (Right) + JDown
Ctrl(Right) + Alt(Right) + Shift (Right) + KUp
Ctrl(Right) + Alt(Right) + Shift (Right) + LRight
Ctrl(Right) + Alt(Right) + Shift (Right) + TAlways on Top (In Power Toys)

Mac OSโ€‹

Required softwareโ€‹

Configurationโ€‹

Because we want to avoid any possible conflicts with keyboard shortcuts defined by other applications we will use the key combination: Ctrl + Option + Shift + Command as our modifier.

We can then define all our global shortcuts based on this modifier.

Since CAPS lock is often not used by people and is positioned such that it is easy to reach we can remap CAPS-LOCK to Ctrl + Option + Shift + Command.

The result is that we now have our easy-to-reach modifier key that we can use to define global shortcuts that are unlikely to override shortcuts defined in the operating system or in other applications.

Armed with the above modifier we can now create shortcuts that map H, J, K, L to the arrow keys allowing navigating in any application by holding down caps-lock.

Configure CAPS-Lockโ€‹

  1. Open Karabiner Elements and add the following configuration.
{
"manipulators": [
{
"description": "Change caps_lock to command+control+option+shift.",
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": ["any"]
}
},
"to": [
{
"key_code": "left_shift",
"modifiers": ["left_command", "left_control", "left_option"]
}
],
"type": "basic"
}
]
}

Setup shortcuts.โ€‹

  1. Open Karabiner Elements and add the following configuration to map H, J, K, L with our special caps-lock modifier to the arrow keys.
{
"description": "Change shift+command+control_option to arrow keys",
"manipulators": [
{
"from": {
"key_code": "h",
"modifiers": {
"mandatory": [
"left_shift",
"left_command",
"left_control",
"left_option"
],
"optional": ["any"]
}
},
"to": [
{
"key_code": "left_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "j",
"modifiers": {
"mandatory": [
"left_shift",
"left_command",
"left_control",
"left_option"
],
"optional": ["any"]
}
},
"to": [
{
"key_code": "down_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "k",
"modifiers": {
"mandatory": [
"left_shift",
"left_command",
"left_control",
"left_option"
],
"optional": ["any"]
}
},
"to": [
{
"key_code": "up_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "l",
"modifiers": {
"mandatory": [
"left_shift",
"left_command",
"left_control",
"left_option"
],
"optional": ["any"]
}
},
"to": [
{
"key_code": "right_arrow"
}
],
"type": "basic"
}
]
}